/**
 * 
 */
package com.cyou.qb.common.service.mock;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Component;

import com.cyou.nad.datastore.DataList;
import com.cyou.nad.datastore.query.JdbcPage;
import com.cyou.qb.common.domain.Award;
import com.cyou.qb.common.domain.AwardDetail;
import com.cyou.qb.common.domain.FrontAward;
import com.cyou.qb.common.service.AwardService;
import com.cyou.qb.system.ServiceContext;

/**
 * @author zoudongchao
 *
 */
@Component("AwardServiceMock")
public class AwardServiceMock implements AwardService {

	public AwardDetail findAwardDetail(int awardId) {
		AwardDetail awardDetail = new AwardDetail();
		awardDetail.setId(1);
		awardDetail.setAwardId(awardId);
		awardDetail.setCardNo("1234");
		awardDetail.setCardNo("***");
		awardDetail.setCreateDate(new Date());
		return awardDetail;
	}

	private Award newOneAward(int awardId) {
		Award award = new Award();
		award.setId(awardId);
		award.setActiveId(1);
		award.setName("魔兽点卡第" + awardId + "张");
		award.setChannel("点卡");
		award.setImage("a.img");
		award.setUrl("http://xxx.xxx.xxx.xxx:xxxx/imgs/xx/a.img");
		award.setMaxNum(100);
		award.setCurrNum(50);
		award.setNumWin(10);
		return award;
	}

	public Award findAward(int awardId) {
		return newOneAward(awardId);
	}

	/**
	 * 返回奖品列表<br>
	 * 根据不同的type参数返回不同的奖品列表
	 * 1 指定
	 * 2 时间
	 * 3 尾数
	 * 4 all<br>
	 * activeId相当于要生成的奖品个数
	 */
	public List<Award> findAwards(int activeId, int type) {
		List<Award> awardList = new ArrayList<Award>();
		if (type == MockConstants.AWARD_LIST_ALL) {
			for (int i = 0; i < activeId; i++) {
				Award award = this.newOneAward(i + 1);
				if (i % 3 == 0) {//设置成指定用户
					award.setWinType(1);
				} else if (i % 3 == 1) {//时间
					award.setWinType(2);
					award.setDateWin("11:" + i + "0:00;12:" + i + "0:00");
				} else if (i % 3 == 2) {//尾数
					award.setWinType(MockConstants.AWARD_LIST_SEQ);
					award.setNumWin(i+1);
				}
				award.setActiveId(activeId);
				awardList.add(award);
			}
		} else if (type == MockConstants.AWARD_LIST_ASSIGNED) {
			for (int i = 0; i < activeId; i++) {
				Award award = this.newOneAward(i+1);
				award.setWinType(1);
				award.setActiveId(activeId);
				awardList.add(award);
			}
		} else if (type == MockConstants.AWARD_LIST_TIME) {
			for (int i = 0; i< activeId; i++){
				Award award = this.newOneAward(i+1);
				award.setWinType(2);
				award.setActiveId(activeId);
				award.setDateWin("11:" + i + "0:00;12:" + i + "0:00");
				
				awardList.add(award);
			}

		} else if (type == MockConstants.AWARD_LIST_SEQ) {
			for (int i =0 ; i< activeId; i++){
				Award award = this.newOneAward(i+1);
				award.setWinType(3);
				award.setActiveId(activeId);
				award.setNumWin(i+1);
				awardList.add(award);
			}

		}
		//需要反序
		Collections.reverse(awardList);
		return awardList;
	}

	public void updateAwardCurrNum(Award award) {
		int curr = award.getCurrNum();
		award.setCurrNum(curr - 1);
	}

	/* (non-Javadoc)
	 * @see com.cyou.qb.common.service.AwardService#removeAward(java.util.List)
	 */
	@Override
	public int removeAward(String awardId) {
		return 0;
	}






	@Override
	public void setServiceContext(ServiceContext serviceContext) {
	}

	@Override
	public ServiceContext getServiceContext() {
		return null;
	}

	@Override
	public List<Award> findAwards(int activeId) {
		return this.findAwards(activeId, MockConstants.AWARD_LIST_ALL);
	}

	/**
	 * Description
	 * @author lidongwei
	 * @since 2012-10-9 下午1:18:34
	 * @see TODOsome class
	 */
	@Override
	public int saveOneAward(String awardNmae, String type, String minitype, String useAdd, String memo,
			String awardImageUrl, int adminId, String activityId) {
		return 0;
	}

	/**
	 * Description
	 * @author lidongwei
	 * @since 2012-10-9 下午6:25:11
	 * @see TODOsome class
	 */
	@Override
	public void updateOnewAward(String awardId, String awardName, String type, String minitype, String useAdd,
			String memo, String awardImageUrl, int adminId) throws Exception {
		
	}

	/**
	 * Description
	 * @author lidongwei
	 * @since 2012-10-9 下午7:38:51
	 * @see TODOsome class
	 */
	@Override
	public JdbcPage pageQueryAward(String activeId, int pageNo, int pageSize) {
		return null;
	}

	/**
	 * Description
	 * @author lidongwei
	 * @since 2012-10-9 下午8:36:48
	 * @see TODOsome class
	 */
	@Override
	public int findSurplusGb(String awardId) {
		return 0;
	}

	@Override
	public int findActiveMaxAwardNum(int activeId) {
		return 0;
	}

	/**
	 * Description
	 * @author lidongwei
	 * @since 2012-10-10 下午2:02:50
	 * @see TODOsome class
	 */
	@Override
	public void updateStoreEntity(String awardId, String awardNum) {
		
	}

	/**
	 * Description
	 * @author lidongwei
	 * @since 2012-10-10 下午4:06:16
	 * @see TODOsome class
	 */
	@Override
	public void updateStoreExperience(String awardId, String experienceNum, String experienceAmount) {
		
	}

	/**
	 * Description
	 * @author lidongwei
	 * @since 2012-10-10 下午4:33:42
	 * @see TODOsome class
	 */
	@Override
	public void updateStoreGb(String awardId, String gbnum, String gbAmount) {
		
	}

	/**
	 * Description
	 * @author lidongwei
	 * @since 2012-10-10 下午6:31:37
	 * @see TODOsome class
	 */
	@Override
	public int saveAwardDetails(String[] txtArray, String awardId) {
		return 0;
	}

	

	/**
	 * Description
	 * @author lidongwei
	 * @since 2012-10-11 下午10:26:28
	 * @see TODOsome class
	 */
	@Override
	public int findCurrNum(String awardId) {
		return 0;
	}

	/**
	 * Description
	 * @author lidongwei
	 * @since 2012-10-13 下午4:06:58
	 * @see TODOsome class
	 */
	@Override
	public DataList findAwardsByActId(String activeId) {
		return null;
	}

	/**
	 * Description
	 * @author lidongwei
	 * @since 2012-10-15 下午7:33:40
	 * @see TODOsome class
	 */
	@Override
	public void updateAddToAward(String awardId, String addToNum) {
		
	}

	



	/**
	 * Description
	 * @author lidongwei
	 * @since 2012-10-16 下午1:46:02
	 * @see TODOsome class
	 */
	@Override
	public JdbcPage pageQueryEntity(String awardId, String userNick, String userId, int pageNo, int pageSize) {
		return null;
	}

	/**
	 * Description
	 * @author lidongwei
	 * @since 2012-10-16 下午1:46:02
	 * @see TODOsome class
	 */
	@Override
	public JdbcPage pageQueryVirtual(String awardId, String vUserNick, String vUserId, String vWin, int pageNo,
			int pageSize) {
		return null;
	}

	/**
	 * Description
	 * @author lidongwei
	 * @since 2012-10-16 下午1:47:41
	 * @see TODOsome class
	 */
	@Override
	public JdbcPage pageQueryGBAndExp(String awardId, String userNick, String userId, int pageNo,
			int pageSize) {
		return null;
	}

	/**
	 * Description
	 * @author lidongwei
	 * @since 2012-10-16 下午7:53:34
	 * @see TODOsome class
	 */
	@Override
	public void updateNoVirNum(String awardId, String newCurrNum) throws Exception {
		
	}

	

	/**
	 * Description
	 * @author lidongwei
	 * @since 2012-10-16 下午9:05:27
	 * @see TODOsome class
	 */
	@Override
	public void removeVirtual(List<String> virtualIdList, String awardId) throws Exception {
		
	}

	@Override
	public List<FrontAward> findAwardList() throws Exception {
		return null;
	}

	@Override
	public int updateOneAwardDetail(AwardDetail awardDetail) throws Exception {
		return 0;
	}

	/**
	 * Description
	 * @author lidongwei
	 * @since 2012-10-30 上午10:42:08
	 * @see TODOsome class
	 */
	@Override
	public List<Integer> findNumWinListByActId(String activeId) {
		return null;
	}

	@Override
	public void freeServiceContextContext() {
		// TODO Auto-generated method stub
		
	}

	


}
